import React, { useEffect, useState } from "react";
import Item from "./item";
import pubsub from 'pubsub-js';
export default function List() {
    const [headPortrait , setHeadPortrait] = useState({
        isInit: true,
        isSearch: false,
        data: [],
      })
    useEffect(() => {
        pubsub.subscribe('github',( _ , data ) => {
            setHeadPortrait(data)
        })
    })
  return (
    <div>
      <div className="row">
        {
            headPortrait.isInit?(<h2>请开始搜索</h2>):headPortrait.isSearch?(<h2>正在搜索中</h2>):(headPortrait.data.map(item => {
                return <Item key={item.id} {...item}/>
            }))
        }
      </div>
    </div>
  );
}
